import Mock from 'mockjs'

const LoginUsers = Mock.mock({
  'roles|1': ['admin', 'editor'],
  name: '@cname',
  avatar: '/static/avatar.png',
  menu: [
    {
      menuId: 1,
      parentId: 0,
      parentName: null,
      name: '导航一',
      url: null,
      perms: null,
      type: 0,
      icon: 'el-icon-message',
      orderNum: 0,
      component: null,
      open: null,
      list: [
        {
          menuId: 2,
          parentId: 1,
          parentName: null,
          name: '表格测试',
          url: 'table',
          perms: null,
          type: 1,
          icon: 'fa fa-table',
          orderNum: 1,
          open: null,
          component: 'Table',
          list: null
        },
        {
          menuId: 3,
          parentId: 1,
          parentName: null,
          name: '表单测试',
          url: 'form',
          perms: null,
          type: 1,
          icon: 'fa fa-book',
          orderNum: 2,
          open: null,
          component: 'Form',
          list: null
        },
        {
          menuId: 4,
          parentId: 1,
          parentName: null,
          name: '复杂表单',
          url: 'complexform',
          perms: null,
          type: 1,
          icon: 'fa fa-user',
          orderNum: 3,
          open: null,
          component: 'ComplexForm',
          list: null
        },
        {
          menuId: 5,
          parentId: 1,
          parentName: null,
          name: '选项卡',
          url: 'tab',
          perms: null,
          type: 1,
          icon: 'fa fa-cube',
          orderNum: 3,
          open: null,
          component: 'Tab',
          list: null
        }
      ]
    },
    {
      menuId: 6,
      parentId: 0,
      parentName: null,
      name: '导航二',
      url: null,
      perms: null,
      type: 0,
      icon: 'el-icon-setting',
      orderNum: 4,
      open: null,
      component: null,
      list: [
        {
          menuId: 7,
          parentId: 6,
          parentName: null,
          name: '测试1',
          url: 'test1',
          perms: null,
          type: 1,
          icon: 'fa fa-cogs',
          orderNum: 5,
          open: null,
          component: null,
          list: null
        },
        {
          menuId: 8,
          parentId: 6,
          parentName: null,
          name: '测试2',
          url: null,
          perms: null,
          type: 0,
          icon: 'fa fa-trash',
          orderNum: 6,
          open: null,
          component: null,
          list: [
            {
              menuId: 9,
              parentId: 8,
              parentName: null,
              name: '测试2-1',
              url: 'test21',
              perms: null,
              type: 1,
              icon: 'fa fa-user',
              orderNum: 7,
              open: null,
              component: 'ComplexForm',
              list: null
            },
            {
              menuId: 10,
              parentId: 8,
              parentName: null,
              name: '测试2-2',
              url: 'test22',
              perms: null,
              type: 1,
              icon: 'fa fa-user-secret',
              orderNum: 8,
              open: null,
              component: null,
              list: null
            }
          ]
        }
      ]
    }
  ]
})

const Users = []

// mockjs用法示例
// name: '@cname', // 中文名称
// 'id|+1': 88, // 属性值自动加 1，初始值为88
// 'age|18-28': 0, // 18至28以内随机整数, 0只是用来确定类型
// birthday: '@date("yyyy-MM-dd")', // 日期
// city: '@city(true)', // 中国城市
// color: '@color', // 16进制颜色
// 'isMale|1': true, // 布尔值
// 'isFat|1-2': true, // true的概率是1/3
// 'fromObj|2': obj, // 从obj对象中随机获取2个属性
// 'fromObj2|1-3': obj, // 从obj对象中随机获取1至3个属性
// 'brother|1': ['jack', 'jim'], // 随机选取 1 个元素
// 'sister|+1': ['jack', 'jim', 'lily'], // array中顺序选取元素作为结果
// 'friends|2': ['jack', 'jim'] // 重复2次属性值生成一个新数组

for (let i = 0; i < 75; i++) {
  Users.push(
    Mock.mock({
      id: Mock.mock('@increment'),
      name: Mock.Random.cname(),
      'sex|1': ['男', '女'],
      addr: Mock.mock('@county(true)'),
      region: Mock.mock('@region'),
      birth: Mock.Random.date(),
      'education|1': ['大专', '本科', '硕士', '博士'],
      zip: Mock.mock('@zip'),
      email: Mock.mock('@email')
    })
  )
}

export { LoginUsers, Users }
